package com.manulife.hk.performance.domains;

import com.manulife.hk.performance.converter.LocalDateTimeConverter;
import com.manulife.hk.performance.converter.OffsetDateTimeConverter;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name = "submit_sale", schema = "performance")
public class SubmitSaleEntity {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	@Column(nullable = false, length = 20)
	private String submitSalesKey;

	@Column(nullable = false, length = 2)
	private String submitSalesSubKey;

	@Column(length = 20)
	private String submitSalesCaptureKey;

	@Column(nullable = false, length = 10)
	private String submitType;

	@Convert(converter = OffsetDateTimeConverter.class)
	@Column(nullable = false)
	private LocalDateTime submitDateTime;

	@Column(nullable = false, precision = 18, scale = 2)
	private BigDecimal submitApe;

	@Column(nullable = false, length = 3)
	private String lob;

	@Column(nullable = false, length = 3)
	private String sysCode;

	@Column(nullable = false, length = 20)
	private String contractNum;

	@Column(length = 10)
	private String subGroupNum;

	@Column(length = 10)
	private String certificateNum;

	@Column(nullable = false, precision = 7, scale = 4)
	private BigDecimal agentSplitPct;

	@Column(nullable = false, length = 6)
	private String agentCode;

	@Column(nullable = false, length = 20)
	private String basicPlanCode;

	@Column(length = 2)
	private String basicPlanVersNum;

	@Column(nullable = false, length = 20)
	private String coveragePlanCode;

	@Column(length = 2)
	private String coveragePlanVersNum;

	@Column(nullable = false, length = 1)
	private String isBasicPlan;

	@Column(nullable = false, precision = 11)
	private BigDecimal submitPc;

	@Column(nullable = false, precision = 3, scale = 2)
	private BigDecimal submitCaseCount;

	@Column(length = 30)
	private String appInKey;

	@Column(nullable = false, length = 30)
	private String salesSource;

	@Column(length = 101)
	private String proposalOwnerName;

	@Column(length = 101)
	private String proposalInsuredName;

	@Column(length = 250)
	private String basicPlanNameEng;

	@Column(length = 250)
	private String basicPlanNameChi;

	@Column(length = 250)
	private String coveragePlanNameEng;

	@Column(length = 250)
	private String coveragePlanNameChi;

	@Column(nullable = false, length = 50)
	private String lastUpdateUser;

	@Convert(converter = LocalDateTimeConverter.class)
	@Column(nullable = false)
	private LocalDateTime lastUpdateDateTime = LocalDateTime.now();
}
